home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
051-075
/
scopedisk70
/
magus110
/
mprintit.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-03-19
|
7KB
|
248 lines
/*---------------------------- Start REXX Source ----------------------------*/
/* MPrintIt.rexx Revised 15-APR-89
Magus! Print Spooler
v1.10 Associated files: Magus!.rexx
Magus!Cntl.rexx
by Magus!Util.rexx
Dan Schenck MPrint.rexx
Tulsa, OK
GEnie: D.SCHENCK
(918) 492-0523
*/
/* Requires rexxarplib.library v2.1 */
parse arg head_pointer cc
active_trigger = GetEnv('update_time')
interrupt = 'NOTE---> PRINT PROCESS INTERRUPTED'
schar = '\f'
rchar = '0C'X
call look4spec_char
schar = '\n'
rchar = '0A'X
call look4spec_char
rtn = Setenv('printit_pgm','ACTIVE')
do forever
rtn = Setenv('current_print',head_pointer)
rtn = Setenv('%_read',0)
do while(Getenv('prnt_spooler') = 'GETTINGCLIP')
call delay(25)
end
rtn = Setenv('prnt_spooler','GETTINGCLIP')
instring = Getenv(head_pointer)
rtn = Setenv('prnt_spooler','NA')
parse VAR instring fwrd_pointer ' ' file2print ' ' orig_file ' ' copies ' ' lpp ' ' p_no ' ' date ' ' time ' ' file
orig_file = translate(orig_file," ","^")
file2print = translate(file2print," ","^")
call printit
do while(Getenv('prnt_spooler') = 'GETTINGCLIP')
call delay(25)
end
rtn = Setenv('prnt_spooler','GETTINGCLIP')
instring = Getenv(head_pointer)
parse VAR instring fwrd_pointer ' ' rest
rtn = Setenv(head_pointer,'null')
if fwrd_pointer = 'null' then
do
rtn = Setenv('printit_pgm','NA')
rtn = Setenv('current_print','null')
rtn = Setenv('spool_tail','null')
rtn = Setenv('prnt_spooler','NA')
address "MAGUSPORT" "DONE"
exit
end
rtn = Setenv('prnt_spooler','NA')
head_pointer = fwrd_pointer
end
printit: procedure expose file2print orig_file cc copies lpp p_no date time file active_trigger interrupt
if ~exists(file2print) then
do
say '"' || file2print || '" Does Not Exist"'
return
end
total_bytes = copies * word(statef(file2print),2)
bytes_read = 0
if lpp ~= 'null' then
do
count_lines = 1
if (p_no ~= 'null') & (substr(p_no,1,1) = 'b') then lpp = lpp - 2
else nop
end
else count_lines = 0
dt_string = ""
file_string = ""
if upper(date) = 'ON' then dt_string = 'Date: ' || date() || ' '
if upper(time) = 'ON' then dt_string = dt_string || 'Time: ' || time()
if upper(file) = 'ON' then file_string = 'File: ' || orig_file
do i = 1 to copies
call time('Reset')
t0 = 0
total_lines = 0
count = 0
page = -1
do while(~open('out','PRT:','Write'))
call delay(300)
end
if count_lines then
do
call new_page
call page_minder(cc)
if dt_string ~= "" then call page_minder(dt_string)
else nop
if file_string ~= "" then call page_minder(file_string)
else nop
call page_minder(' ')
end
else
do
call writeln('out',cc)
if dt_string ~= "" then call writeln('out',dt_string)
if file_string ~= "" then call writeln('out',file_string)
call writeln('out',' ')
end
call open('pfile',file2print,'Read')
total_rcds = 0
rec_chk = 10
do while(~eof('pfile'))
if Getenv('printit_pgm') = 'ABORT' then
do
call close('pfile')
if count_lines then call page_minder(interrupt)
else call writeln('out',interrupt)
call close('out')
if (index(upper(file2print),"++M!SPOOL/++") > 0) then
address command 'delete' file2print || " Quiet"
rtn = Setenv('printit_pgm','ACTIVE')
return
end
instring = readln('pfile')
bytes_read = bytes_read + length(instring)
total_rcds = total_rcds + 1
if total_rcds = rec_chk then
do
rec_chk = rec_chk + 10
rtn = Setenv('%_read',(bytes_read/total_bytes*100))
if time('E')-t0 > active_trigger then
do
address MAGUSPORT "UPDATE"
t0 = time('E')
end
end
if count_lines then
do
if right(instring,1) = '0C'X then
do
if count >= lpp then call new_page
else nop
call writeln('out',left(instring,length(instring)-1))
total_lines = total_lines + 1
call new_page
end
else
do
if count >= lpp then call new_page
else nop
call writeln('out',instring)
count = count + 1
total_lines = total_lines + 1
end
end
else call writeln('out',instring)
end
if count_lines then
do
call page_minder('0A'X || 'Total records in file = ' || total_rcds || ' Total lines printed = ' || total_lines+2 || ' Seconds to print = ' || time('E'))
if (count > 0) & (substr(p_no,1,1) = 'b') then call new_page
end
else call writeln('out','Total records in file = ' || total_rcds || ' Seconds to print = ' || time('E'))
call close('pfile')
call close('out')
call delay(50)
if (index(upper(file2print),"++M!SPOOL/++") > 0) then
address command 'delete' file2print || " Quiet"
end
return
look4spec_char: procedure expose cc schar rchar
spec_char = index(cc,schar)
do while(spec_char > 0)
if (spec_char + 2) > length(cc) then cc_rest = ""
else cc_rest = substr(cc,spec_char+2)
if spec_char = 1 then cc = ""
else cc = substr(cc,1,spec_char-1)
cc = cc || rchar || cc_rest
spec_char = index(cc,schar)
end
return
page_minder: procedure expose count lpp total_lines p_no page
parse arg instring
if right(instring,1) = '0C'X then
do
if count >= lpp then call new_page
call writeln('out',left(instring,length(instring)-1))
total_lines = total_lines + 1
call new_page
return
end
if count >= lpp then call new_page
call writeln('out',instring)
count = count + 1
total_lines = total_lines + 1
return
new_page: procedure expose count p_no page total_lines
ff = '0C'X
if p_no ~= 'null' then
do
page = page + 1
t_or_b = substr(p_no,1,1)
if page = 0 then
if t_or_b = 'b' then
do
call writech('out',ff)
return
end
else page = 1
else nop
total_lines = total_lines + 2
if t_or_b = 't' then call writech('out',ff)
else call writeln('out',' ')
where = substr(p_no,2,1)
page_text = 'Page ' || page
select
when where = 'l' then call writeln('out',page_text)
when where = 'c' then call writeln('out',center(page_text,80))
when where = 'r' then call writeln('out',copies(' ',80-length(page_text)) || page_text)
end
if t_or_b = 't' then
do
count = 2
call writeln('out',' ')
end
else
do
count = 0
call writech('out',ff)
end
end
else
do
call writech('out',ff)
count = 0
end
return
/*----------------------------- End REXX Source -----------------------------*/